def is_prime(num):
    if num < 2:
        return False
    for i in range(2, int(num ** 0.5) + 1):
        if num % i == 0:
            return False
    return True


start = int(input())
end = int(input())

for num in range(start, end + 1):
    reverse_num = int(str(num)[::-1])
    if num != reverse_num and is_prime(num) and is_prime(reverse_num):
        print(num)